<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .clock {
            position: relative;
            margin: 0 auto;
            width: 600px;
            height: 600px;
            background: url('./clock.jpg') no-repeat center;
        }

        .clock>div {
            position: absolute;
            top: 0;
            left: 0;
        }

        .hour {
            margin: 0 auto;
            width: 600px;
            height: 600px;
            background: url('./hour.png') no-repeat center;
        }

        .minuto {
            margin: 0 auto;
            width: 600px;
            height: 600px;
            background: url('./minute.png') no-repeat center;
        }

        .second {
            margin: 0 auto;
            width: 600px;
            height: 600px;
            background: url('./second.png') no-repeat center;
        }
    </style>
</head>

<body>
    <div class="clock">
        <div class="hour"></div>
        <div class="minuto"></div>
        <div class="second"></div>
    </div>
</body>
<script>
    function $(selected) {
        return document.querySelector(selected);
    }

    function sit() {
        var currentTime = new Date()
        // 获取毫秒数
        var ms = currentTime.getMilliseconds()
        // 获取到当前的秒数
        var sec = currentTime.getSeconds() + ms / 1000
        // 获取到当前的分钟数
        var min = currentTime.getMinutes() + sec / 60
        // 获取到当前的小时数
        var hour = currentTime.getHours() + min / 60

        // 一小时旋转30度
        $('.hour').style.transform = "rotate(" + hour * 30 + "deg)"
        // 一分钟旋转6度
        $('.minuto').style.transform = "rotate(" + min * 6 + "deg)"
        //  一秒钟旋转6度
        $('.second').style.transform = "rotate(" + sec * 6 + "deg)"
    }
    setInterval(sit, 1000)
</script>

</html>